package com.ebways.rpc.service.order;

import com.ebways.rpc.service.User;
import com.ebways.rpc.service.UserService;
import com.ebways.rpc.service.UserService2;
import com.ebways.rpc.service.consumer.RpcConsumer;

import java.util.List;

/**
 * Created by gmq on 2017/08/29.
 *
 * @version 1.0
 * @since 2017/08/29 11:05
 */
public class OrderBiz {

    public void execute(int id) {
        // 订单系统业务逻辑处理
        // 需要获取用户id
        UserService userService = (UserService) RpcConsumer.remote(UserService.class);
        User user = userService.getUser(id);
        // user就是我们需要的
        System.out.println("收到用户系统返回的信息-" + user.getName());

        UserService2 userService2 = (UserService2) RpcConsumer.remote(UserService2.class);

        List<User> list = userService2.getList();
        for (User u : list) {
            System.out.println("u.id =" + u.getId() + " - " + u.getName());
        }

    }

    public static void main(String[] args) {
        OrderBiz orderBiz = new OrderBiz();
        orderBiz.execute(10);
    }
}
